<!--
  To change this template, choose Tools | Templates
  and open the template in the editor.
-->

<%@ page contentType="text/html;charset=UTF-8" %>

<html>
  <head>
    <meta name="layout" content="main">
    <title>${user?.username}</title>
  </head>
  <body>
    <div id="bd">
      
      <div id="facilityLeftSide">
        <h3>Forums Created</h3>
        <g:each var="forum" in="${user.forums}">
          <g:link controller="forum" action="view" params="[facilityName: forum.facility.name, topic: forum.topic]">${forum.topic}</g:link>
        </g:each>
      </div>
      
      <div id="facilityRightSide" style="float: right; max-width: 120px">
        <h3>Recent Posts</h3>
        <g:each var="post" in="${recentPosts}">
          <g:link controller="forum" action="view" params="[facilityName: post.forum.facility.name, topic: post.forum.topic]">${post.message}</g:link>
          </br></br>
        </g:each>
      </div>
      
      <div id="facilityInfo">
        <h1>${user?.username} Profile</h1>
        <h2>${role}</h2>
        </br>
        <h3>Information</h3>
        <div id="addressInfo">
          <table>
            <tr>
              <td>Username: </td>
              <td style="padding-left: 10px">${user.username}</td>
            </tr>
            <tr>
              <td>First Name: </td>
              <td style="padding-left: 10px">${user.firstName}</td>
            </tr>
            <tr>
              <td>Last Name: </td>
              <td style="padding-left: 10px">${user.lastName}</td>
            </tr>
            <tr>
              <td>Email: </td>
              <td style="padding-left: 10px">${user.email}</td>
            </tr>
          </table>
        </div> 
          
        </br>
        <g:link action="editInfo" params="[username: user.username]">Edit Information</g:link>
      </div>
      
      <div style="clear: both"></div>
      
      <h2>Options</h2>
      <sec:ifAllGranted roles="ROLE_OWNER">
        <g:link action="viewUpgrades">View Upgrade Requests</g:link>
        </br>
        <g:link controller="facility" action="register">Register New Facility</g:link>
        </br>
      </sec:ifAllGranted>
      
      <sec:ifAnyGranted roles="ROLE_MODERATOR, ROLE_CONTRIBUTOR">
        <g:if test="${!madeRequest}">
          <g:link action="requestUpgrade">Request Upgrade</g:link>
        </g:if>
        <g:else>
          Upgrade Requested
        </g:else>
      </sec:ifAnyGranted>
    </div>
    
  </body>
</html>
